package com.txy.service.impl;

import com.txy.dao.EmployeeDao;
import com.txy.dao.impl.EmployeeDaoImpl;
import com.txy.entity.Employee;
import com.txy.service.EmployeeService;
import com.txy.util.PageInfo;
import com.txy.vo.EmployeeParam;

import java.util.List;

/**
 * Author：汤小洋
 * Date：2022-11-08 16:23
 * Description：<描述>
 */
public class EmployeeServiceImpl implements EmployeeService {
    EmployeeDao employeeDao = new EmployeeDaoImpl();

    @Override
    public List<Employee> findAll() {
        return employeeDao.selectAll();
    }

    @Override
    public void removeById(int id) {
        employeeDao.deleteById(id);
    }

    @Override
    public void add(Employee emp) {
        employeeDao.insert(emp);
    }

    @Override
    public Employee findById(int id) {
        return employeeDao.selectById(id);
    }

    @Override
    public void modify(Employee emp) {
        employeeDao.update(emp);
    }

    @Override
    public PageInfo<Employee> findByPage(int pageNo, int pageSize, EmployeeParam param) {
        List<Employee> list = employeeDao.selectByPage(pageNo, pageSize, param);

        int total = employeeDao.selectCount(param);

        PageInfo<Employee> pageInfo = new PageInfo<>(total, pageNo, pageSize, list);

        return pageInfo;
    }

}
